#! /usr/bin/env python
# -*- coding: utf-8 -*-

from utils.get_time import get_str_date

company_name = '福建优力特材料有限公司'
company_id = '1820379858379681793'
danger_name = '测试重大危险源-xmj'
danger_id = '测试重大危险源-xmj'
evaluation_level = '低风险'
evaluation_level_key = 4
evaluation_start_date = '2025-08-24'
evaluation_end_date = '2025-08-24'
# 测试查看的数据编号
seq = 1

# 断言数据的列编号
column_score = 4
column_level = 3
column_rank = 0

# 查看页面断言的数据
score = '综合评分: '
level = '动态评级: '
rank = '动态排名: '

query_sql = '''
select count(*) from (
SELECT
	rmsper.id
FROM
	hgyq_emergency.rp_m_safe_production_evaluate_result rmsper
WHERE
	rmsper.is_deleted = 0 
	AND rmsper.grade_name = "''' + str(evaluation_level_key) + '''"
	AND rmsper.create_time BETWEEN "''' + evaluation_start_date + '''" AND "''' + evaluation_end_date + '''"
	AND rmsper.create_dept = ''' + company_id + '''
	AND rmsper.source = "ha_great_control"
	AND rmsper.obj_id IN ( SELECT id FROM hgyq_synthetical.ha_m_great_risk_bill 
	WHERE NAME LIKE "%''' + danger_name + '''%" AND is_deleted = 0 AND create_dept = ''' + company_id + '''
	 )
) t
'''

# 评价结果页面默认查询，默认只显示昨天的评价记录
reset_sql_result = '''
SELECT
	count(*)
FROM
	hgyq_emergency.rp_m_safe_production_evaluate_result rmsper
WHERE
    DATE_FORMAT(create_time, '%Y-%m-%d') = ''' + get_str_date(-1) + '''
	AND rmsper.is_deleted = 0 
	AND rmsper.source = "ha_great_control"
	AND rmsper.create_dept = ''' + company_id + '''
	AND rmsper.obj_id IN ( SELECT id FROM hgyq_synthetical.ha_m_great_risk_bill 
	WHERE create_dept = ''' + company_id + ''' AND is_deleted = 0
	 )
'''

# 历史记录页面默认查询
reset_sql_history = '''
SELECT
	count(*)
FROM
	hgyq_emergency.rp_m_safe_production_evaluate_result rmsper
WHERE
	rmsper.is_deleted = 0 
	AND rmsper.source = "ha_great_control"
	AND rmsper.create_dept = ''' + company_id + '''
	AND rmsper.obj_id IN ( SELECT id FROM hgyq_synthetical.ha_m_great_risk_bill 
	WHERE create_dept = ''' + company_id + ''' AND is_deleted = 0
	 )
'''
